#include "main/utils.h"
using namespace std;

class Solution {
public:
    bool canJump(vector<int>& nums) {
      int last = 0;
      for (int i = 0; i < nums.size(); ++i) {
        if (last >= i) {
          last = max(last, i + nums[i]);
          if (last >= nums.size() - 1) {
            return true;
          }
        }
      }
      return false;
    }
};

int main() {
  vector<int> nums = {2, 3, 1, 1, 4};
  Solution su;
  cout << su.canJump(nums) << endl;

  return 0;
}
